package com.jadows.tdog.message.handler.pipline.impl;

import com.jadows.tdog.domain.ChatMessage;
import com.jadows.tdog.message.handler.pipline.IMessageProcess;
import com.jadows.tdog.repository.ChatMessageRepository;
import io.netty.channel.Channel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 消息持久化加工
 *
 * @author taojiacheng
 */
@Service("messagePersistenceProcess")
@RequiredArgsConstructor
@Slf4j
public class MessagePersistenceProcess implements IMessageProcess {

    final ChatMessageRepository chatMessageRepository;

    @Override
    public ChatMessage handlerMessage(ChatMessage message, Channel channel) {
        return chatMessageRepository.save(message);
    }

}
